﻿using UnityEngine;
using System.Collections;

namespace DragonRescue3D
{
    /// <summary>
    /// Draws particles in the direction oif the rocket before firing
    /// </summary>
    public class LineOfSite : MonoBehaviour
    {
        public float _speed = 1.0f;
        public float _resetTime = 1.0f;
        float _originalYPos = 0.0f;
        public Rocket Rocket;

        /// <summary>
        /// Initialises the particle object's vertical position and invokes a method to reset 
        /// the position regularly
        /// </summary>
        void Start()
        {
            _originalYPos = transform.position.y;
            InvokeRepeating("ResetPosition", _resetTime, _resetTime);
        }

        /// <summary>
        /// Handles the particle object based on the rocket's state
        /// </summary>
        void Update()
        {
            // Is the rocket is being positioned then tanslate the particles vertical postion
            // to mimic the position/direction the rocket when fired 
            if (Rocket.IsActive)
            {
                transform.Translate(Vector3.up * _speed);
            }
            else if (Rocket.HasFired) // Else the rocket has already fired so we are no longer needed
            {
                Destroy(gameObject);
            }
        }

        /// <summary>
        /// Rest the vertical position of the line-of-site particle object
        /// </summary>
        void ResetPosition()
        {
            transform.position = new Vector3(transform.position.x, _originalYPos, transform.position.z);
        }
    }
}

#if NO_AND_ERROR
public void TEXT1() 
{
	int textNum = 1;
	if (textNum == 1) 
	{
		textNum = 2;
    }
}
public void TEXT2()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}
public void TEXT3()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT4()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT5()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT6()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT8()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT9()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT10()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT11()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT12()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT13()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT14()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT15()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT16()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT17()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}
#endif